Skip to content

Add sync and async test cases for azure-resource-manager-method-subscription-id mock API tests#3205

Merged
msyyc merged 6 commits intomainfrom
copilot/fix-3204
Sep 12, 2025
Merged

Add sync and async test cases for azure-resource-manager-method-subscription-id mock API tests#3205
msyyc merged 6 commits intomainfrom
copilot/fix-3204

Conversation

Copy link
Contributor

Copilot AI commented Sep 11, 2025

  • Add test cases for azure-resource-manager-method-subscription-id mock API tests
  • Fix cspell spelling errors for methodsubscriptionid word
  • Format test file with black formatter
  • Add async test cases under packages/typespec-python/test/azure/mock_api_tests/asynctests

This PR adds comprehensive test coverage for the azure-resource-manager-method-subscription-id generated SDK by implementing both sync and async test files in the mock API tests folder, fixes the spelling errors detected by cspell, and formats the test files with black.

Overview

The new test files provide complete coverage for all operations defined in the Azure Resource Manager Method Subscription ID specification, testing the unique behavior of method-level vs client-level subscription ID parameter placement.

Test Coverage

The implementation includes 13 test functions covering:

Operations Group

  • test_operations_list() - Validates the operations listing endpoint

TwoSubscriptionResourcesMethodLevel Group

Tests for resources where subscription ID is moved from client-level to method-level:

  • SubscriptionResource1Operations: get, put, delete operations
  • SubscriptionResource2Operations: get, put, delete operations

MixedSubscriptionPlacement Group

Tests mixed parameter placement scenarios:

  • SubscriptionResourceOperations: get, put, delete with method-level subscription ID
  • ResourceGroupResourceOperations: get, put, delete with client-level subscription ID

Key Features

  • Method-level subscription ID testing: Validates that certain operations correctly require subscription_id as a method parameter rather than using the client-level parameter
  • Mixed placement validation: Tests scenarios where some operations use method-level subscription ID while others use client-level
  • Proper resource models: Uses appropriate model classes (SubscriptionResource1, SubscriptionResource2, SubscriptionResource, ResourceGroupResource) with correct properties
  • Expected data validation: Assertions match the expected request/response data defined in the mockapi specifications
  • Async support: Complete async versions of all test cases following the established async test patterns

Implementation Details

The test files follow the established patterns from existing mock API tests:

  • Sync tests: Uses MethodSubscriptionIdClient from azure.resourcemanager.methodsubscriptionid
  • Async tests: Uses MethodSubscriptionIdClient from azure.resourcemanager.methodsubscriptionid.aio with proper async/await patterns
  • Implements proper pytest fixtures for client setup with fake credentials and authentication policy
  • Follows the same assertion patterns as reference tests but with method-subscription-id specific expected data
  • Maintains consistent code style and structure with existing test files
  • Code formatting: Applied black formatter to ensure consistent Python code style

Cspell Fix

Added methodsubscriptionid to the cspell.yaml words list to resolve spelling check errors in the test files.

This ensures comprehensive validation of the method-level subscription ID parameter placement functionality in Azure Resource Manager operations for both sync and async clients.

Fixes #3204.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…hensive test coverage

Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Copilot AI changed the title [WIP] Add test cases Add test cases for azure-resource-manager-method-subscription-id mock API tests Sep 11, 2025
Copilot AI requested a review from msyyc September 11, 2025 07:51
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Copilot AI changed the title Add test cases for azure-resource-manager-method-subscription-id mock API tests Add sync and async test cases for azure-resource-manager-method-subscription-id mock API tests Sep 11, 2025
Copilot AI requested a review from msyyc September 11, 2025 11:36
@msyyc msyyc marked this pull request as ready for review September 12, 2025 00:59
@msyyc msyyc merged commit 423bd8e into main Sep 12, 2025
14 checks passed
@msyyc msyyc deleted the copilot/fix-3204 branch September 12, 2025 01:00
github-merge-queue bot pushed a commit to microsoft/typespec that referenced this pull request Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test cases

2 participants